﻿using Atlanchim.Crm.Mui.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Atlanchim.Crm.Mui.Pages
{
    public abstract class AbstractPageListModel : INotifyPropertyChanged
    {
        public string Complement { get; set; }

        /// <summary>
        /// Url pour la création d'une nouvelle entité
        /// </summary>
        public string NewEntityUrl { get; set; }

        //---------------------------------------------------------------------------------------------------------------------------------------
        #region Chargement

        private string _fragment = string.Empty;
        /// <summary>
        /// Paramètre passé à la page via l'url
        /// </summary>
        public string Fragment
        {
            get { return this._fragment; }
            set
            {
                this._fragment = value;

                if (!string.IsNullOrEmpty(this._fragment))
                {
                    this.DicFragments = FragmentHelper.Split(this._fragment);
                }
            }
        }

        public Dictionary<string, string> DicFragments { get; set; }

        /// <summary>
        /// Méthode de chargement à surcharger
        /// </summary>
        public abstract void Load();

        #endregion Chargement
        //---------------------------------------------------------------------------------------------------------------------------------------


        //---------------------------------------------------------------------------------------------------------------------------------------
        #region INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion INotifyPropertyChanged
        //---------------------------------------------------------------------------------------------------------------------------------------
    }
}
